package com.msgqu.share.domain.common;

/**
 * @description:
 * @author: wsj
 * @create: 2020-11-20 17:47
 * @throws:
 */
public class Result {
    private Integer code;
    private String msg;
    private Object data;
    private Long timestamp = System.currentTimeMillis();

    public Result(){}
    public Result(Integer code,String msg,Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.timestamp = System.currentTimeMillis();
    }
    public static Result success(Integer code,String msg,Object data){
        return new Result(code,msg,data);
    }
    public static Result success(String msg,Object data){
        return new Result(200,msg,data);
    }
    public static Result success(Object data){
        return new Result(200,"",data);
    }
    public static Result fail(Integer code,String msg,Object data){
        return new Result(code,msg,data);
    }
    public static Result fail(String msg,Object data){
        return new Result(500,msg,data);
    }
    public static Result fail(Object data){
        return new Result(500,"",data);
    }
    public static Result fail(String msg){
        return new Result(500,msg,null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                ", timestamp=" + timestamp +
                '}';
    }
}
